//
//  QZShortPlayVC.m
//  shortvideoplay
//
//  Created by tikeios_002 on 2024/9/23.
//

#import "QZShortPlayVC.h"
#import "CSJADLoading.h"
//#import "NewPagedFlowView.h"
//#import "PGIndexBannerSubiew.h"
//#import "SYCollectionViewRoundFlowLayout.h"
//#import "QZShortPlayVCCollectionViewCell.h"
//#import "QZMyDetailsPlayVC.h"

@interface QZShortPlayVC ()

@end

@implementation QZShortPlayVC

- (void)showOldAddNavViewToMainOldView1{
    UIView * oldBgSS = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    oldBgSS.clipsToBounds = YES;
       UILabel * oldshowSSSSTip = [[UILabel alloc]init];
    oldshowSSSSTip.clipsToBounds = YES;
    oldshowSSSSTip.text = @"kass显示区";
    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip.hidden = YES;
    [self.view addSubview:oldshowSSSSTip];
    [self.view addSubview:oldBgSS];
    
    UIButton * sendBtn = [[UIButton alloc]initWithFrame:CGRectMake(KScreen_W-75, kStatusBarHeight+10, 60, 46)];
    sendBtn.layer.cornerRadius = 3;
    sendBtn.backgroundColor = [UIColor whiteColor];
    [sendBtn setTitle:@"发送" forState:UIControlStateNormal];
    [sendBtn setTitleColor:ColorHex(@"#333333") forState:UIControlStateNormal];
    sendBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [sendBtn addTarget:self action:@selector(sendTap) forControlEvents:UIControlEventTouchUpInside];
    [oldBgSS addSubview:sendBtn];
    
    UIView * sendBg = [[UIView alloc]initWithFrame:CGRectMake(15, kStatusBarHeight+66, KScreen_W-30, (KScreen_H-KSafeAreaBottomHeight-25-(kStatusBarHeight+66))/2)];
    sendBg.backgroundColor = [UIColor whiteColor];
    sendBg.layer.cornerRadius = 3;
    [oldBgSS addSubview:sendBg];
    
    UILabel * sendTip = [[UILabel alloc]initWithFrame:CGRectMake(0, (sendBg.frame.size.height-40)/2, sendBg.frame.size.width, 40)];
    sendTip.text = @"发送区";
    sendTip.textColor = ColorHex(@"#f0f0f0");
    sendTip.textAlignment = NSTextAlignmentCenter;
    sendTip.font = [UIFont systemFontOfSize:28];
    [sendBg addSubview:sendTip];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    

    DJXPlayletAggregatePageViewController *vc = [[DJXPlayletAggregatePageViewController alloc] initWithConfigBuilder:^(DJXPlayletAggregatePageVCConfig * _Nonnull config) {
        DJXPlayletConfig *playletConfig = [DJXPlayletConfig new];
        if([[QZUserInfoModel share].mid intValue] == 2){
            playletConfig.freeEpisodesCount = 10000;
        }else if([[QZUserInfoModel share].iscreator intValue] == 1){
            playletConfig.freeEpisodesCount = 20;
        }else{
            playletConfig.freeEpisodesCount = 5;
        }
        playletConfig.unlockEpisodesCountUsingAD = 5;
        playletConfig.playletUnlockADMode = DJXPlayletUnlockADMode_Common;
        config.playletConfig = playletConfig;
        config.isShowNavigationItemTitle = YES;
        config.isShowNavigationItemBackButton = NO;
    }];

    [self addChildViewController:vc];
    
    UILabel * oldshowSSSSTip = [[UILabel alloc]init];
    oldshowSSSSTip.clipsToBounds = YES;
    oldshowSSSSTip.text = @"kass显示区";
    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip.hidden = YES;
    [self.view addSubview:oldshowSSSSTip];
    [self.view addSubview:vc.view];
//    _pageFlowView = [[NewPagedFlowView alloc] initWithFrame:CGRectMake(0, 72, KScreen_W, KScreen_W * 9 / 16)];
//    _pageFlowView.delegate = self;
//    _pageFlowView.dataSource = self;
//    _pageFlowView.minimumPageAlpha = 0.1;
//    _pageFlowView.isCarousel = YES;
//    _pageFlowView.orientation = NewPagedFlowViewOrientationHorizontal;
//    _pageFlowView.isOpenAutoScroll = YES;
//
//    //初始化pageControl
//    _pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, _pageFlowView.frame.size.height - 32, KScreen_W, 8)];
//    _pageFlowView.pageControl = _pageControl;
//    [_pageFlowView addSubview:_pageControl];
//    [self.view addSubview:_pageFlowView];
    
//    KWeakSelf
//    self.historyCollection.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
//        weakSelf.requestPage = weakSelf.requestPage+1;
//        [weakSelf djRequest];
//    }];
//    self.historyCollection.mj_header = [MJRefreshGifHeader headerWithRefreshingBlock:^{
//        //下拉刷新要做的操作.
//        [weakSelf.historyCollection.mj_footer resetNoMoreData];
//        [weakSelf.videoArray removeAllObjects];
//        [weakSelf.historyCollection reloadData];
//        [weakSelf djRequest];
//    }];
//    
//    _videoArray = [NSMutableArray new];
//    _requestPage = 1;
//    
//    [SVProgressHUDTool showToastMessage:nil];
//    [self djRequest];
}
//- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
//    NSLog(@"");
//}
//- (void)djRequest{
//    KWeakSelf
//    [CSJADLoading dj_requestAllPlayletListPage:self.requestPage successBlock:^(NSArray<DJXPlayletInfoModel *> * _Nonnull playletList) {
//        if(playletList == nil){
//            [YBMsgPop showPop:@"短剧列表加载失败"];
//        }else{
//            [weakSelf.videoArray addObjectsFromArray:playletList];
//        }
//        [SVProgressHUDTool dismiss];
//    }];
//}
//- (UICollectionView *)historyCollection{
//    if(_historyCollection == nil){
//
//        SYCollectionViewRoundFlowLayout *layout = [[SYCollectionViewRoundFlowLayout alloc]init];
//        layout.sectionHeadersPinToVisibleBounds = YES;
//        layout.collectionCellAlignmentType = SYCollectionViewFlowLayoutAlignmentTypeByLeft;
//        _historyCollection = [[UICollectionView alloc]initWithFrame:CGRectMake(0, KNav_H, KScreen_W, KScreen_H-KNav_H-KTab_H) collectionViewLayout:layout];
//        [_historyCollection registerNib:[UINib nibWithNibName:@"QZShortPlayVCCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"QZShortPlayVCCollectionViewCell"];
//        _historyCollection.backgroundColor = viewback_black;
//
//        _historyCollection.alwaysBounceVertical = YES;
//        _historyCollection.delegate = self;
//        _historyCollection.dataSource = self;
//           UILabel * oldshowSSSSTip = [[UILabel alloc]init];
//    oldshowSSSSTip.clipsToBounds = YES;
//    oldshowSSSSTip.text = @"kass显示区";
//    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
//    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
//    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
//    oldshowSSSSTip.hidden = YES;
//    [self.view addSubview:oldshowSSSSTip];
//    [self.view addSubview:_historyCollection];
//    }
//    return _historyCollection;
//}
//- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
//    return 1;
//}
//- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
//    return self.videoArray.count;
//}
//- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
//    QZShortPlayVCCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QZShortPlayVCCollectionViewCell" forIndexPath:indexPath];
//    [cell findsShoeCell:self.videoArray[indexPath.row]];
//    return cell;
//}
//
//- (void)showTextViewSubViewToViewTo1:(UIView * )subView{
//
//    UIView * showTextViewSubViewTo1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
//    showTextViewSubViewTo1.clipsToBounds = YES;
//    [subView addSubview:showTextViewSubViewTo1];
//    UILabel * showTextViewSubViewLabelTo2 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
//    showTextViewSubViewLabelTo2.text = @"56464645";
//    [showTextViewSubViewTo1 addSubview:showTextViewSubViewLabelTo2];
//
//    UIImageView * showTextViewSubViewTo2 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
//    [subView addSubview:showTextViewSubViewTo2];
//
//}
//- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
//    QZMyDetailsPlayVC * play = [[QZMyDetailsPlayVC alloc]init];
//    play.isAdShow = YES;
//    play.videoArr = [[NSMutableArray alloc]initWithArray:self.videoArray];
//    play.videoPlayIndex = indexPath.row;
//    [self.navigationController pushViewController:play animated:YES];
//}
//
//#pragma mark NewPagedFlowView Delegate
//- (CGSize)sizeForPageInFlowView:(NewPagedFlowView *)flowView {
//    return CGSizeMake(KScreen_W - 60, (KScreen_W - 60) * 9 / 16);
//}
//
//- (void)didSelectCell:(UIView *)subView withSubViewIndex:(NSInteger)subIndex {
//    NSLog(@"点击了第%ld张图",(long)subIndex);
//}
//
//- (void)didScrollToPage:(NSInteger)pageNumber inFlowView:(NewPagedFlowView *)flowView {
//    NSLog(@"ViewController 滚动到了第%ld页",pageNumber);
//}
//
//#pragma mark NewPagedFlowView Datasource
//- (NSInteger)numberOfPagesInFlowView:(NewPagedFlowView *)flowView {
//
//    return self.pageArray.count;
//
//}
//
//- (PGIndexBannerSubiew *)flowView:(NewPagedFlowView *)flowView cellForPageAtIndex:(NSInteger)index{
//    PGIndexBannerSubiew *bannerView = [flowView dequeueReusableCell];
//    if (!bannerView) {
//        bannerView = [[PGIndexBannerSubiew alloc] init];
//        bannerView.tag = index;
//        bannerView.layer.cornerRadius = 4;
//        bannerView.layer.masksToBounds = YES;
//    }
//    //在这里下载网络图片
//    bannerView.mainImageView.image = self.pageArray[index];
//
//    return bannerView;
//}
@end
